package com.king.java.tools.email.entity;


import com.king.java.tools.email.SimpleEmaliMessageConfig;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 描述: 邮件实体信息
 *
 * @author : sujinchen
 * @date : 2020/10/12
 */
public class EmailEntity implements SimpleEmaliMessageConfig {
    /**
     * 收件人地址
     */
    private List<String> recipientAddress=new ArrayList<>();
    /**
     * 抄送人地址
     */
    private  List<String> copyAddress=new ArrayList<>();
    /**
     * 密送人地址
     */
    private  List<String> secretAddress=new ArrayList<>();
    /**
     * 邮件主题
     */
    private String title;
    /**
     * 邮件正文
     */
    private List<String> context= new ArrayList();
    /**
     * 图片地址
     */
    private List<String> images= new ArrayList();
    /**
     * 附件地址
     */
    private List<String> accessorys= new ArrayList();
    /**
     * 发件时间
     */
    private Date date=new Date();
    /**
     * 是否发送
     */
    private boolean isSend = true;
    /**
     * 是否本地保存
     */
    private boolean isSave = false;

    /**
     * 注册表
     * 0>>文本
     * 1>>图片
     * 2>>附件
     */
    private List<Integer>registry = new ArrayList();

    /**
     * 传入收件人地址进行构造
     * @param recipientAddress 收件人地址
     */
    public EmailEntity(String recipientAddress) {
        addRecipientAddress(recipientAddress);
    }

    /**
     * 传入收件人地址和标题进行构造
     * @param recipientAddress 收件人地址
     * @param title 标题
     */
    public EmailEntity(String recipientAddress, String title) {
        addRecipientAddress(recipientAddress);
        setTitle(title);
    }

    public EmailEntity(List<String> recipientAddress, String title) {
        this.recipientAddress = recipientAddress;
        this.title = title;
    }

    public EmailEntity(List<String> recipientAddress, List<String> copyAddress, String title) {
        this.title = title;
        this.recipientAddress = recipientAddress;
        this.copyAddress = copyAddress;
    }

    public EmailEntity(List<String> recipientAddress, List<String> copyAddress, List<String> secretAddress, String title) {
        this.title = title;
        this.recipientAddress = recipientAddress;
        this.copyAddress = copyAddress;
        this.secretAddress = secretAddress;
    }


    /**
     * 设置邮件标题
     * @param title 邮件标题
     */
    @Override
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * 为邮件实体添加文本内容并在注册表中注册，0代表文本
     * @param text 文本信息或html文本
     */
    @Override
    public void addTextContent(String text) {
        registry.add(0);
        context.add(text);
    }

    /**
     * 为邮件实体添加图片内容并在注册表中注册，1代表图片
     * @param filePath
     */
    @Override
    public void addPicture(String filePath) {
        registry.add(1);
        images.add(filePath);
    }

    /**
     * 为邮件实体添加附件内容并在注册表中注册，2代表附件
     * @param filePath
     */
    @Override
    public void addAccessory(String filePath) {
        registry.add(2);
        accessorys.add(filePath);
    }


    /**
     * 添加收件人
     * @param recipientAddress 收件人地址
     */
    @Override
    public void addRecipientAddress(String recipientAddress) {
        this.recipientAddress.add(recipientAddress);
    }

    /**
     * 添加抄件人
     * @param copyAddress 抄送人地址
     */
    @Override
    public void addCopyAddress(String copyAddress) {
        this.copyAddress.add(copyAddress);
    }

    /**
     * 添加密送人
     * @param secretAddress 密送人地址
     */
    @Override
    public void addSecretAddress(String secretAddress) {
        this.secretAddress.add(secretAddress);
    }

    public List<String> getRecipientAddress() {
        return recipientAddress;
    }

    public List<String> getCopyAddress() {
        return copyAddress;
    }

    public List<String> getSecretAddress() {
        return secretAddress;
    }

    public String getTitle() {
        return title;
    }

    public List<String> getContext() {
        return context;
    }

    public List<String> getImages() {
        return images;
    }

    public List<String> getAccessorys() {
        return accessorys;
    }

    public Date getDate() {
        return date;
    }

    public boolean isSend() {
        return isSend;
    }

    public boolean isSave() {
        return isSave;
    }

    public List<Integer> getRegistry() {
        return registry;
    }
}
